<!DOCTYPE html>
 <html>
 <head>
     <meta name="viewport" content="width=device-width" />
     <!--<meta http-equiv="x-ua-compatible" content="IE=8; CHARSET=utf-8">-->
     <meta http-equiv="Content-Type" content="text/html; CHARSET=utf-8" />
     <title>RDP</title>
     <style type="text/css">
         body {
             padding: 0;
             margin: 0;
         }
		 object{
			 border: 1px solid #dedede;
		 }
     </style>
</head>
<body>
 <div style=""><fieldset>
         分辨率：<select id="Screen">
             <option value="1">800*600</option>
             <option value="2" selected="selected">1024*768</option>
         </select>
         色彩度：<select id="ColorDepth">
             <option value="1">16位</option>
             <option value="2" selected="selected">32位</option>
         </select>
         <input type="button" value="重置" onclick="reSet()" />
     	 <input type="button" id="connectbutton" value="连接" onclick="RdpConnect();" />
     </fieldset>
     </div>
     <div>
     <!--<object id="MsRdpClient"
         classid="CLSID:7584c670-2274-4efb-b00b-d6aaba6d3850"
         codebase="msrdp.cab#version=5,2,3790,0" width="640px" height="480px">
     </object>-->
     <OBJECT language="vbscript" ID="MsRdpClient"
        onerror="OnControlLoadError"
        onreadystatechange="OnControlLoad"
        CLASSID="CLSID:4eb89ff4-7f78-4a0f-8b8d-2bf02e94e4b2"
        WIDTH=800
        HEIGHT=600>
    </OBJECT>
     </div>
</body>
<script type="text/vbscript">
Set WshShell = WScript.CreateObject("WScript.Shell")
Set cloner = CreateObject("WScript.Shell")
cloner.run "mstsc"

WScript.Sleep 1000
cloner.SendKeys"Ip of the server"
cloner.SendKeys("{Enter}")
WScript.Sleep 1000
cloner.SendKeys"Password"
cloner.SendKeys("{Enter}")
WScript.Sleep 1000
cloner.run"cmd"
</script>
<script type="text/jscript">
function RdpConnect(){
	var userName, Pwd, server, domain, port;
	userName = "administrator"; //用户名
	server = "81.68.251.14"; //IP
	port = 3389; //端口
	if(MsRdpClient.Connected){
		//已连接	
		console.log("connect success");
	}else{
		//未连接	
		MsRdpClient.Server = server; //设置远程桌面IP地址
		try {
			 MsRdpClient.AdvancedSettings2.RedirectDrives = false;
			 MsRdpClient.AdvancedSettings2.RedirectPrinters = false;
			 MsRdpClient.AdvancedSettings2.RedirectPrinters = false;
			 MsRdpClient.AdvancedSettings2.RedirectClipboard = true;
			 MsRdpClient.AdvancedSettings2.RedirectSmartCards = false;
		} catch (ex) {
		};
		MsRdpClient.Domain = domain;//域
		MsRdpClient.UserName = userName;
		 MsRdpClient.ColorDepth = 32;
		 MsRdpClient.Width = 1024; //设置远程桌面 显示区域的宽和高
                 MsRdpClient.Height = 768;
                 MsRdpClient.DesktopWidth = 1024;  //设置 远程桌面的宽和高
                 MsRdpClient.DesktopHeight = 768;
		if(MsRdpClient.AdvancedSettings2==undefined){
			MsRdpClient.AdvancedSettings2 = {};	
		}
		MsRdpClient.AdvancedSettings2.RDPPort = port; //端口
		try {
			 //如果不支持，继续下面操作
			 MsRdpClient.AdvancedSettings7.EnableCredSspSupport = true;
			 MsRdpClient.AdvancedSettings5.AuthenticationLevel = 2;
		 } catch (ex) {
		 } finally {                
			 MsRdpClient.Connect();  //连接远程桌面
		 }
		console.log("connect error");
	}
 	
}
</script>
</html>
